﻿using System;
using System.Configuration;
using NetDiskPRJ.Common.DEncrypt;
namespace NetDiskPRJ.DBUtility
{

    public class PubConstant
    {
        private static string connectionString;
        /// <summary>
        /// 获取连接字符串
        /// </summary>
        public static string ConnectionString
        {
            get
            {
                //string _connectionString = ConfigurationManager.AppSettings["ConnectionString"];
                //string ConStringEncrypt = ConfigurationManager.AppSettings["ConStringEncrypt"];
                //if (ConStringEncrypt == "true")
                //{
                //    _connectionString = DESEncrypt.Decrypt(_connectionString);
                //}
                //return _connectionString;
                return connectionString;
            }
            set
            {
                connectionString = value;
            }
        }
        /// <summary>
        /// 根据值返回是否为dbnull
        /// 字符串为空也返回DBNull.Value
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static object CheckNullToDbNull(object obj)
        {
            if (obj == null)
            {
                return DBNull.Value;
            }
            else
            {
                if (string.Empty == obj.ToString())
                {
                    return DBNull.Value;
                }
                else
                {

                    return obj;
                }
            }
        }

       


    }
}
